# -*-encoding=utf8 -*-

import json

from django.views import View
from utils.response import CommonResponseMixin

from django.http import JsonResponse,HttpResponse

from thirdparty import juhe


class WeatherView(View,CommonResponseMixin):
    def get(self, request):
        pass

    def post(self,request):
        data = []
        received_body = request.body.decode('utf-8')
        received_body = json.loads(received_body)
        location = received_body.get('location')
        result = juhe.weather(location)
        result1 = juhe.weatherFuture(location)
        data.append(result)
        data.append(result1)
        data = self.wrap_json_response(data=data)
        return JsonResponse(data=data,safe=False)
        pass
